package com.info.zhiduoduo.admin.controller;

import com.info.zhiduoduo.admin.model.formbean.report.EditReasonsForOverdueFormBean;
import com.info.zhiduoduo.admin.model.formbean.report.ReportListFormBean;
import com.info.zhiduoduo.admin.service.ReportService;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import com.info.zhiduoduo.repository.dto.report.CountDetailDto;
import com.info.zhiduoduo.repository.dto.report.RealtimePendingItemDto;
import com.info.zhiduoduo.repository.entity.report.DailyReportDto;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

import io.swagger.annotations.ApiOperation;

@Api(tags = "统计报表")
@RequestMapping("/report")
@RestController
public class ReportController {

	@Autowired
	ReportService reportService;

	@ApiOperation("获取日报列表")
	@PostMapping("/dailyList")
	public SmartResult<DailyReportDto> listReport(@RequestBody BaseSimpleFormBean<ReportListFormBean> formBean) {
		return reportService.listReport(formBean);
	}

	@ApiOperation("逾期首次交易工作室未开票数详情")
	@PostMapping("/listUnfinishUntaxAcctInvoiceDetail")
	public SmartResult<CountDetailDto> listUnfinishUntaxAcctInvoiceDetail() {
		return reportService.listUnfinishUntaxAcctInvoiceDetail();
	}

	@ApiOperation("逾期非首次交易工作室未开票数详情")
	@PostMapping("/listUnfinishTaxAcctInvoiceDetail")
	public SmartResult<CountDetailDto> listUnfinishTaxAcctInvoiceDetail() {
		return reportService.listUnfinishTaxAcctInvoiceDetail();
	}

	@ApiOperation("编辑逾期理由")
	@PostMapping("/editReasonsForOverdue")
	public SmartResult editReasonsForOverdue(@RequestBody BaseSimpleFormBean<EditReasonsForOverdueFormBean> formBean) {
		return reportService.editReasonsForOverdue(formBean);
	}


	@ApiOperation("逾期未开工作室详情")
	@PostMapping("/listUnopenStudioDetail")
	public SmartResult<CountDetailDto> listUnopenStudioDetail() {
		return reportService.listUnopenStudioDetail();
	}

	@ApiOperation("逾期未开税户详情")
	@PostMapping("/listUnopenTaxAcctDetail")
	public SmartResult<CountDetailDto> listUnopenTaxAcctDetail() {
		return reportService.listUnopenTaxAcctDetail();
	}

	@ApiOperation("逾期未审核企业详情")
	@PostMapping("/listUnfinishCompany")
	public SmartResult<CountDetailDto> listUnfinishCompany() {
		return reportService.listUnfinishCompany();
	}

	@ApiOperation("逾期未审核创客详情")
	@PostMapping("/listUnfinishMaker")
	public SmartResult<CountDetailDto> listUnfinishMaker() {
		return reportService.listUnfinishMaker();
	}

	@ApiOperation("逾期未开户创客列表")
	@PostMapping("/listUnOpenAliPayMaker")
	public SmartResult<CountDetailDto> listUnOpenAliPayMaker(@RequestBody BaseSimpleFormBean baseSimpleFormBean) {
		return reportService.listUnOpenAliPayMaker(baseSimpleFormBean);
	}

	@ApiOperation("获取实时代办事项")
	@GetMapping("/realtimePendingItems")
	public SmartResult<RealtimePendingItemDto> getRealtimePendingItems(@RequestParam("userid") int userid) {
		return reportService.getRealtimePendingItems(userid);
	}

	@PostMapping("/collectData")
	public SmartResult collectData(@RequestParam("date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) {
		reportService.collectReportStatistic(date);
		return SmartResult.success();
	}

	@ApiOperation("获取企业交易状态统计数量")
	@PostMapping("/companyTradeQuantity")
	public SmartResult companyTradeQuantity(@RequestBody BaseSimpleFormBean baseSimpleFormBean) {
		return reportService.companyTradeQuantity(baseSimpleFormBean);
	}
}
